var stroage = window.localStorage

export function setItem(key, value) {
  if (stroage) {
    stroage.setItem(key, JSON.stringify(value))
  } else {
    console.log("浏览器不支持")
    ;
  }
}

export function getItem(key) {
  if (stroage) {
    return JSON.parse(stroage.getItem(key));
  } else {
    console.log("浏览器不支持");
  }
}

export function clear() {
  if (stroage) {
    stroage.clear()
  } else {
    console.log("浏览器不支持")
  }
}

export function setCity(cityId, cityName) {
  var city = {
    id: cityId,
    cityName: cityName
  };
  stroage.setItem("city", JSON.stringify(city));
}

